home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 526-550 / disk_541 / steal / src / showscr.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  137 lines

  1. /****************************************************************************
  2.  
  3.                 ShowScr.c
  4.  
  5.     This file should be linked together with a compiled version
  6.     of Stolen.c, or whatever it's name may be. That file must
  7.     contain the following:
  8.      - A NewScreen structure: The Screen to be shown;
  9.      - A list of NewWindows: The Windows to be opened on it;
  10.      - A list of Menus: The Menu for the Window at the according index.
  11.  
  12.                     Rick van Rein, October 2, 1990
  13.  
  14. ****************************************************************************/
  15.  
  16.  
  17.  
  18. #include <functions.h>
  19.  
  20. #include <Intuition/Intuition.h>
  21.  
  22.  
  23. struct IntuitionBase *IntuitionBase;
  24. struct GfxBase *GfxBase;
  25.  
  26. extern struct NewWindow *swin1 [];    /* Ending in NULL */
  27. extern struct Menu *smen1 [];        /* Congruent with latter, but NULL means "no MenuStrip" */
  28.  
  29. extern struct NewScreen nscr1;        /* The Screen itself */
  30. extern short cols1 [];            /* The Screen's colours */
  31.  
  32.  
  33. /***** This routine opens a Window with a Close-Gadget in it: */
  34.  
  35.  
  36. #define BLUE_0      0
  37. #define WHITE_1     1
  38. #define BLACK_2     2
  39. #define ORANGE_3    3
  40.  
  41.  
  42. struct NewWindow closewin =
  43.  {
  44.    30,30,                    /* LeftEdge,TopEdge */
  45.    360,10,                    /* Width,Height */
  46.    BLUE_0,WHITE_1,                /* DetailPen,BlockPen */
  47.    CLOSEWINDOW,                    /* IDCMPFlags */
  48.    WINDOWDRAG | WINDOWDEPTH | WINDOWCLOSE | SMART_REFRESH,
  49.                         /* Flags */
  50.    NULL,                    /* FirstGadget */
  51.    NULL,                    /* CheckMark */
  52.    (UBYTE *) " <<< Click here to finish ShowScr ",
  53.                         /* Title */
  54.    NULL,                    /* Screen */
  55.    NULL,                    /* BitMap */
  56.    -1,-1,                    /* MinWidth,MinHeight */
  57.    -1,-1,                    /* MaxWidth,MaxHeight */
  58.    WBENCHSCREEN                    /* Type */
  59.  };
  60.  
  61. void WaitForClick ()
  62.  {
  63.    struct Window *win;
  64.  
  65.    if (win=OpenWindow (&closewin))
  66.     {
  67.       WaitPort (win->UserPort);
  68.       ReplyMsg (GetMsg (win->UserPort));    /* Our Gadget was Clicked */
  69.       CloseWindow (win);
  70.     }
  71.    else
  72.       puts ("\tShowScr: Can't open Window on Workbench Screen");
  73.  }
  74.  
  75.  
  76. /***** The main routine of the showing mechanism: */
  77.  
  78. main ()
  79.  {
  80.    struct Screen *scr;
  81.    struct NewWindow **wp;
  82.    struct Window *win,*next;
  83.    struct Menu **mp;
  84.    int ok;
  85.  
  86.    if (!(IntuitionBase=(struct IntuitionBase *) OpenLibrary ("intuition.library",0L)))
  87.     {
  88.       puts ("\tShowScr: Can't open intuition.library (?)");
  89.       exit (0);
  90.     }
  91.    if (!(GfxBase=(void *) OpenLibrary ("graphics.library",0L)))
  92.     {
  93.       puts ("\tShowScr: Can't open graphics.library (?)");
  94.       exit (0);
  95.     }
  96.  
  97.    scr=OpenScreen (&nscr1);
  98.    if (!scr)
  99.     {
  100.       puts ("\tShowScr: Can't open Screen as defined by scr1");
  101.       exit (0);
  102.     }
  103.  
  104.    LoadRGB4 (&scr->ViewPort,cols1,1L << nscr1.Depth);
  105.  
  106.    wp=swin1;
  107.    mp=smen1;
  108.    ok=1;
  109.    while (ok && *wp)
  110.     {
  111.       (*wp)->Screen=scr;
  112.       (*wp)->Type=CUSTOMSCREEN;
  113.       win=OpenWindow (*wp);
  114.       if ((ok=(win!=NULL)) && *mp)
  115.          SetMenuStrip (win,*mp);
  116.       wp++;
  117.       mp++;
  118.     }
  119.  
  120.    if (ok)
  121.       WaitForClick ();
  122.    else
  123.       puts ("\tShowScr: Not all Windows as described in swin1 could be opened");
  124.  
  125.    win=scr->FirstWindow;
  126.    while (win)
  127.     {
  128.       next=win->NextWindow;
  129.       CloseWindow (win);
  130.       win=next;
  131.     }
  132.    CloseScreen (scr);
  133.  
  134.    CloseLibrary (GfxBase);
  135.    CloseLibrary (IntuitionBase);
  136.  }
  137.